Video signal coding method and coding device

ABSTRACT

A video signal coding device is provided with unit dividing means ( 202 ) for dividing an input picture into units each of which is a coding quantity control unit consisting of one or a plurality of frames to be processed by any one of intra-frame coding, inter-frame forward coding, and inter-frame bidirectional coding; activity calculating means ( 203 ) for calculating a frame activity for every frame of the input picture, and calculating a unit activity for every unit from the frame activities of frames belonging to the same unit; target coding quantity deciding means ( 205 ) for deciding a target coding quantity of a coding frame on the basis of the frame activity of the coding frame which is a coding object, the unit activity of a coding unit to which the coding unit belongs, and the average unit activity of a unit prior to the coding unit; and coding means ( 206 ) for coding the coding frame by the target coding quantity so as to generate coded data.

TECHNICAL FIELD

[0001] The present invention relates to a highly efficient coding method and apparatus used for recording or transmitting picture signals, and more particularly, to a code amount control system that reduces the total code amount of the whole picture to a predetermined value or less, while restraining the deterioration of picture quality.

BACKGROUND ART

[0002] An example of this type of picture signal coding method is an interframe coding system represented by MPEG (Moving Picture Experts Group). As code amount control in such a coding system, two types of code amount control, that is, (1) intra-GOP interframe code amount control for one GOP (Group of Pictures) and (2) intraframe inter-macro-block code amount control for one frame, are necessary.

[0003] In a TM5 system widely known as a test model of the MPEG, for the above (1) intra-GOP interframe code amount control, the target code amount for a coding frame is found from the activity of previously encoded frames and the remaining code amount. Here, the remaining code amount means a code amount obtained by subtracting the generated code amount of encoded frames from a code amount assigned to a GOP to which the coding frame belongs, that is, a code amount assigned to frames after the coding frame.

[0004] For the above (2) intraframe inter-macro-block code amount control, the quantization parameter for a coding macro block (hereinafter referred to as a scaling factor) is found from the relationship between the generated code amount up to the present time and the target code amount. This system is called a feedback system.

[0005] On the contrary, in a feedforward system, which is also well known for the intraframe inter-macro-block code amount control, a code amount is pre-calculated by using all available scaling factors (in the MPEG 2, 31 scaling factors can be used) and the scaling factor that is the closest to the target code amount among the obtained 31 code amounts is selected as the final scaling factor.

[0006] The scaling factor is a parameter used in quantization. One scaling factor is provided corresponding to one macro block. When the value of the scaling factor is small, the macro block is quantized in a smaller quantization step. On the contrary, when the value of the scaling factor is large, the macro block is quantized in a larger quantization step.

[0007]FIG. 16 shows a block diagram of a picture signal coding device using a conventional intra-GOP interframe code amount control system. In FIG. 16, 800 denotes a motion vector detection portion, 801 denotes a differential picture generation portion, 802 denotes an activity calculation portion, 803 denotes a target code amount determination portion, 804 denotes a coding portion, 805 denotes an assigned code amount updating portion, and 806 denotes a local decoder.

[0008] A picture signal is inputted to the motion vector detection portion 800 and the differential picture generation portion 801. When the inputted picture type is a P type or B type picture, the motion vector detection portion 800 detects motion vectors with respect to reference picture(s) stored in the memory and outputs the detected motion vectors. When the inputted picture is an I type picture, the motion vector detection portion 800 does not detect motion vectors. The motion vectors outputted from the motion vector detection portion 800 are inputted to the differential picture generation portion 801.

[0009] When the inputted picture type is a P type or B type picture, the differential picture generation portion 801 generates a predicted picture from the inputted motion vectors and decoded reference picture(s) inputted from the local decoder 806 and calculates the differences between the predicted picture and the inputted picture. The differential picture outputted from the differential picture generation portion 801 is inputted to the coding portion 804.

[0010] If there is a frame that is the same picture type in the previously encoded frames, the target code amount determination portion 803 determines a target code amount from the activity of the encoded frame and the remaining code amount. If there is no frame of the same picture type, the target code amount determination portion 803 sets a specific initial value as the target code amount. The target code amount is inputted to the coding portion 804.

[0011] The coding portion 804 encodes the inputted differential picture by the inputted target code amount and outputs encoded data and an average scaling factor. The encoded data is inputted to the activity calculation portion 802, the assigned code amount updating portion 805, and the local decoder 806. The average scaling factor is inputted to the activity calculation portion 802.

[0012] The activity calculation portion 802 calculates a generated code amount from the inputted encoded data, calculates an activity from the inputted average scaling factor and the calculated generated code amount, and updates the activity of the frame of the same picture type as the coding frame to the calculated activity.

[0013] The assigned code amount updating portion 805 calculates a generated code amount from the inputted encoded data and updates the assigned code amount. The local decoder 806 decodes the inputted encoded data and generates a decoded picture.

[0014]FIG. 17 shows a block diagram of the coding portion 804. In FIG. 17, 810 denotes a macro-blocking portion, 811 denotes an orthogonal transformation portion, 812 denotes a quantization portion, 813 denotes an importance calculation portion, 814 denotes a scaling factor determination portion, and 815 denotes a variable length coding portion. A conventional intraframe inter-macro-block code amount control system will be described with reference to this figure.

[0015] A differential picture inputted to the coding portion is inputted to the macro-blocking portion 810. The macro-blocking portion 810 performs the process of blocking and macro-blocking the inputted differential picture. The macro-blocked data is inputted to the orthogonal transformation portion 811 and the importance calculation portion 813.

[0016] The orthogonal transformation portion 811 performs orthogonal transformation for each block and outputs transformation coefficients. The transformation coefficients are inputted to the quantization portion 812. The importance calculation portion 813 calculates an importance for each macro block and outputs the importance data indicating the importance of the macro block.

[0017] The importance data is inputted to the scaling factor determination portion 814. The scaling factor determination portion 814 determines a scaling factor from the importance data of the coding macro block and the remaining code amount. Here, the remaining code amount means a code amount obtained by subtracting the sum of the generated code amounts of macro blocks previously encoded from the target code amount set for the frame, that is, a code amount assigned to the remaining macro blocks including the coding macro block.

[0018] The scaling factor outputted from the scaling factor determination portion 814 is inputted to the quantization portion 812. The quantization portion 812 quantizes the transformation coefficients provided from the orthogonal transformation portion 811 by the inputted scaling factor and outputs quantized data. The quantized data is inputted to the variable length coding portion 815.

[0019] The variable length coding portion 815 performs the variable length coding of the inputted quantized data and outputs encoded data. The encoded data is inputted to the scaling factor determination portion 814. The scaling factor determination portion 814 calculates the generated code amount of the encoded macro block based on the inputted encoded data and updates the remaining code amount.

[0020]FIG. 18 is a block diagram of another configuration of the conventional coding portion 804. In FIG. 18, 820 denotes a macro-blocking portion, 821 denotes an orthogonal transformation portion, 822 denotes a quantization portion, 823 denotes an importance calculation portion, 824 denotes a code amount calculation portion, 825 denotes a final scaling factor determination portion, and 826 denotes a variable length coding portion. A feedforward system, which is another intraframe inter-macro-block code amount control system, will be described with reference to FIG. 18. Only the coding portion will be described as in the above explanation with reference to FIG. 17.

[0021] A differential picture inputted to the coding portion is inputted to the macro-blocking portion 820. The macro-blocking portion 820 performs the process of blocking and macro-blocking the inputted differential picture. The macro-blocked data is inputted to the orthogonal transformation portion 821 and the importance calculation portion 823.

[0022] The orthogonal transformation portion 821 performs orthogonal transformation for each block and outputs transformation coefficients. The transformation coefficients are inputted to the quantization portion 822 and the code amount calculation portion 824. The importance calculation portion 823 calculates an importance for each macro block and outputs importance data indicating the importance of the macro block. The importance data is inputted to the code amount calculation portion 824 and the quantization portion 822.

[0023] The code amount calculation portion 824 has 31 code amount estimation portions. Each code amount estimation portion performs the quantization and variable length coding of the inputted transformation coefficients based on a specific scaling factor and a scaling factor generated from the importance data and calculates the generated code amount of one frame. The generated code amounts according to 31 scaling factors outputted from the code amount calculation portion 824 are inputted to the final scaling factor determination portion 825.

[0024] The final scaling factor determination portion 825 determines a scaling factor providing a generated code amount that is the closest to the target code amount of the coding frame among the inputted 31 generated code amounts as a final scaling factor and outputs the final scaling factor. The final scaling factor is inputted to the quantization portion 822.

[0025] The quantization portion 822 quantizes the macro block of the coding frame based on the inputted final scaling factor and importance data and outputs quantized data. The quantized data is inputted to the variable length coding portion 826. The variable length coding portion 826 performs the variable length coding of the inputted quantized data and outputs encoded data.

[0026] A problem of the conventional intra-GOP interframe code amount control systems as described above is that since the activity of the frames previously encoded is used to determine the target code amount of the coding frame, the assignment of the code amount does not reflect the characteristics of the picture of the coding frame. Furthermore, in the intraframe inter-macro-block code amount control system, the scaling factor used for the quantization of the coding macro block does not reflect the characteristics of the coding macro block sufficiently.

[0027] In addition, the conventional feedforward type intraframe inter-macro-block code amount control system enables control that takes into account the characteristics of the coding macro block, but this system requires a very large scale circuit and a very large number of operations.

SUMMARY OF THE INVENTION

[0028] A coding method according to the present invention is adapted to control code amounts with high precision according to the characteristics of pictures by improving first and second conventional coding methods as defined below.

[0029] The first conventional coding method comprises the steps of defining N continuous frames as one coding control unit, performing intraframe coding of a first frame of the coding control unit without using a difference between frames, coding an Nth frame using a difference between the Nth frame and the first frame, and coding a second frame to a (N−1)th frame using both difference between the second to the (N−1)th frame and the first frame and difference between the second to the (N−1)th frame and the Nth frame.

[0030] The second conventional coding method comprises the steps of defining N continuous frames as one coding control unit, performing intraframe coding of a Kth frame of the coding control unit without using a difference between frames, coding an Nth frame using a difference between the Nth frame and the Kth frame, coding a first frame to a (K−1)th frame using both difference between the first to the (K−1)th frame and the Nth frame of the latest previous coding control unit and difference between the first to the (K−1)th frame and the Kth frame of the current coding control unit, and coding a (K+1)th frame to a (N−1)th frame using both difference between the (K+1)th to the (N−1)th frame and the Kth frame of the current coding control unit and difference between the (K+1)th to the (N−1)th frame and the Nth frame of the current coding control unit.

[0031] According to a first aspect of the coding method of the present invention, in the first conventional coding method, target code amounts of all frames of the coding control unit are set considering the difference between the Nth frame and the first frame as an index.

[0032] According to a second aspect of the coding method of the present invention, in the second conventional coding method, target code amounts of all frames of the current coding control unit are set considering the difference between the Nth frame and the Kth frame as an index.

[0033] According to a third aspect of the coding method of the present invention, in the first conventional coding method, a scene change in the coding control unit is detected based on the motion amount of the Nth frame from the first frame and the motion amounts of the second to the (N−1)th frame from the first frame, and target code amounts of all frames of the coding control unit are set considering the result of the scene change detection as an index.

[0034] According to a fourth aspect of the coding method of the present invention, in the second conventional coding method, a scene change in the coding control unit is detected based on the motion amount of the Nth frame from the Kth frame and the motion amounts of the first to the (K−1)th frame and the (K+1)th to the (N−1)th frame from the Kth frame, and target code amounts of all frames of the coding control unit are set considering the result of the scene change detection as an index.

[0035] According to a fifth aspect of the coding method of the present invention, in the first conventional coding method, the degree of difficulty of coding picture signals in the coding control unit is detected from an activity calculated with respect to the first frame, and target code amounts of all frames of the coding control unit are set considering the degree of difficulty and the difference between the Nth frame and the first frame as indices.

[0036] According to a sixth aspect of the coding method of the present invention, in the second conventional coding method, the degree of difficulty of coding picture signals in the coding control unit is detected from an activity calculated with respect to the Kth frame, and target code amounts of all frames of the coding control unit are set considering the degree of difficulty and the difference between the Nth frame and the Kth frame as indices.

[0037] According to the coding methods as described above, the code amounts can be controlled according to the characteristics of pictures. Especially, changes in pictures in a GOP can be predicted according to the differential information of the P picture. Thus, even in scene-changed pictures or pictures whose motion changes greatly, which are conventionally a problem, code amounts can be assigned according to the characteristics of pictures. Therefore, the process of the present invention can achieve a higher picture quality than conventional processes at the same bit rate. Furthermore, the process of the present invention can achieve the same picture quality at a bit rate lower than that of the conventional processes.

[0038] According to a first aspect of a coding device of the present invention, the coding device comprises a unit division means for divining inputted pictures into coding control units comprising one or plurality of frames that are to be subjected to a process selected from the group consisting of an intraframe coding process, an interframe forward coding process, and an interframe bidirectionally predictive coding process; an activity calculation means for calculating a frame activity from each frame of the inputted pictures and calculating a unit activity for each unit from the frame activities of the frames that belong to the unit; a target code amount determination means for determining the target code amount of a coding frame based on the frame activity of the coding frame, the unit activity of a coding unit to which the coding frame belongs, and the average unit activity of previous units; and a coding means for coding the coding frame with the target code amount to generate encoded data.

[0039] According to the above aspect, the inputted pictures are controlled for each unit, so that code amounts can be controlled according to the characteristics of pictures. It is preferable that the frame activity calculated for each frame is multiplied by one of three weighting constants predetermined according to whether the coding frame is an I, P or B picture type and that the resulting value is used as a new frame activity. Code amounts can be controlled with high precision according to the characteristics of pictures by performing a weighting operation of an activity according to the picture type.

[0040] According to a second aspect of the coding device of the present invention, the coding device comprises an activity function generation means for calculating an activity for each macro block in each frame of inputted pictures, generating an activity function indicating the accumulation of the activity for each macro block in a coding frame, and calculating the frame activity of the coding frame; a target code amount determination means for determining the target code amount of the coding frame by considering at least one of the remaining code amount at the time of coding the coding frame, the generated code amount of previously encoded frames, the activity of the previously encoded frames, the occupancy of a buffer, and the activity of the coding frame; a reference scaling factor calculation means for calculating the reference scaling factor of the coding frame by using at least one of the scaling factor of the previously encoded frames, the generated code amount of the previously encoded frames, the frame activity of the previously encoded frames, the frame activity of the coding frame, and the target code amount; an importance calculation means for detecting a visual importance for each macro block; and a coding means for generating a prediction model based on the activity function and the target code amount, coding the coding frame macro block by macro block by using the prediction model, the reference scaling factor, and the importance, and generating encoded data.

[0041] According to the above aspect, coding is performed along the prediction model generated from the activity reflecting the characteristics of the picture type and the reference scaling factor is controlled by the difference between the prediction model and the generated code amount. Therefore, code amounts can be controlled with high precision according to the characteristics of pictures.

[0042] According to a third aspect of the coding device of the present invention, the coding device comprises an activity function generation means for calculating an activity for each macro block in each frame with respect to inputted pictures, generating an activity function indicating the accumulation of the activity for each macro block in a coding frame, and calculating the frame activity of the coding frame; a target code amount determination means for determining the target code amount of the coding frame by using at least one of the remaining code amount at the time of coding the coding frame, the generated code amount of previously encoded frames, the activity of the previously encoded frames, the occupancy of a buffer, and the activity of the coding frame; a reference scaling factor calculation means for calculating the reference scaling factor of the coding frame by using at least one of the scaling factor of the previously encoded frames, the generated code amount of the previously encoded frames, the frame activity of the previously encoded frames, the frame activity of the coding frame, and the target code amount; an importance calculation means for detecting a visual importance for each macro block; and a coding means for generating a prediction model based on the activity function and the target code amount, setting a region with a specific width with respect to the prediction model, coding the coding frame macro block by macro block by using the reference scaling factor and the importance, correcting at least one of the reference scaling factor, the prediction model, the target code amount, and the region according to a deviation amount when the accumulation of a generated code amount for each macro block deviates from the region, and generating encoded data.

[0043] According to the above aspect, the region with a specific width is set with respect to the prediction model generated from the activity reflecting the characteristics of the picture, coding is performed along the prediction model, and the reference scaling factor is controlled according to the deviation amount when the generated code amount deviates from the region. Therefore, code amounts can be controlled with high precision according to the characteristics of pictures.

[0044] Various preferable embodiments for implementing the second and third aspect of the coding device according to the present invention will be described below.

[0045] First, the coding means sets a check point for each integer macro blocks and determines whether the accumulation of the generated code amount for each macro block deviates from the region at the check point or not. By setting a check point for each integer macro blocks, the fluctuation of the reference scaling factor can be reduced. Therefore, stable regenerated pictures can be provided while performing control with high precision according to the characteristics of pictures.

[0046] In addition, the importance calculation means calculates the importance for each orthogonal transformation block, calculates the sum of absolute values of AC components in orthogonal transformation data of the orthogonal transformation block when the coding system of a coding block is an interframe coding system and when the coding frame is a B picture, and sets the scaling factor of the orthogonal transformation block smaller than the reference scaling factor if the sum of the absolute values is larger than a threshold. By protecting regions for a moving object and regions whose motion vector is large, code amounts can be controlled with high precision according to the characteristics of pictures.

[0047] Furthermore, the importance calculation means calculates the importance for each orthogonal transformation block, calculates the sum of absolute values of AC components in orthogonal transformation data of the orthogonal transformation block when the coding system of a coding block is an interframe coding system and when the coding frame is a B picture, and sets all orthogonal transformation data of the orthogonal transformation block to 0 if the sum of the absolute values is smaller than a threshold. Reproducing still regions and regions where motion vector is effective only by motion compensation, large code amounts can be assigned to other regions. Therefore, code amounts can be controlled with high precision according to the characteristics of pictures.

[0048] Moreover, the importance calculation means calculates the importance for each orthogonal transformation block; calculates the number of sampling values having a larger value than a threshold among the sampling values of a Y-R component block in the orthogonal transformation block with respect to an inputted picture for which a differential operation for motion compensation is not performed, when the coding system of a coding block is an interframe coding system; and sets the scaling factor of the orthogonal transformation block smaller than the reference scaling factor if the number of the sampling values is larger than a predetermined value. By protecting a red color having a high chroma, the picture quality can be improved.

[0049] In addition, the importance calculation means calculates the importance for each orthogonal transformation block; calculates the number of sampling values having a larger value than a threshold among the sampling values of a Y-B component block in the orthogonal transformation block with respect to an inputted picture for which a differential operation for motion compensation is not performed, when the coding system of a coding block is an interframe coding system; and sets the scaling factor of the orthogonal transformation block smaller than the reference scaling factor if the number of the sampling values is larger than a predetermined value. By protecting a blue color having a high chroma, the picture quality can be improved.

[0050] Furthermore, the importance calculation means calculates the importance for each orthogonal transformation block; calculates the number of sampling values having a value in the range of a first threshold to a second threshold with respect to a Y component block in a coding macro block and defines the number of the sampling values as a first detected value, calculates the number of sampling values having a value in the range of a third threshold to a fourth threshold with respect to a Y-R component block in the coding macro block and defines the number of the sampling values as a second detected value, and calculates the number of sampling values having a value in the range of a fifth threshold to a six threshold with respect to a Y-B component block in the coding macro block and defines the number of the sampling values as a third detected value, with respect to an inputted picture for which a differential operation for motion compensation is not performed, when the coding system of a coding block is an interframe coding system; and sets the scaling factor of a coding macro block smaller than the reference scaling factor when the first detected value is larger than a first number, when the second detected value is larger than a second number, and when the third detected value is larger than a third number. By detecting a specific color, for example, a skin color, and protecting the color, the picture quality can be improved.

[0051] Moreover, the importance calculation means calculates the importance for each orthogonal transformation block; calculates the number of sampling values in which the absolute value of a difference between a sampling value of a Y-R component block and a sampling value of a Y-B component block is larger than a threshold with respect to the Y-B component block and the Y-R component block in a coding macro block, with respect to an inputted picture for which a differential operation for motion compensation is not performed, when the coding system of a coding block is an interframe coding system; and sets the scaling factor of a coding macro block smaller than the reference scaling factor if the number of the sampling values is larger than a predetermined value. By protecting red and blue colors having a high chroma, the picture quality can be improved.

[0052] In addition, the importance calculation means calculates the importance for each orthogonal transformation block; calculates the activity of the orthogonal transformation block with respect to an inputted picture for which a differential operation for motion compensation is not performed and calculates the sum of absolute values of AC components in the orthogonal transformation block with respect to a differential picture for which a differential operation for motion compensation is performed when the coding system of a coding block is an interframe coding system; and sets the scaling factor of the orthogonal transformation block larger than the reference scaling factor when the activity is larger than a first threshold and the sum of the absolute values of the AC components is larger than a second threshold. By not protecting regions where visual deterioration is unnoticeable and providing large code amounts to other regions, code amounts can be controlled with high precision according to the characteristics of pictures.

[0053] Furthermore, the importance calculation means calculates the importance for each macro block, and sets the scaling factor of a coding macro block larger than the reference scaling factor when the coding macro block is located at one of the upper end, lower end, left end and right end of the screen. By not protecting regions where visual deterioration is unnoticeable and providing large code amounts to other regions, code amounts can be controlled with high precision according to the characteristics of pictures.

[0054] Moreover, the importance calculation means calculates the importance for each orthogonal transformation block; and sets the scaling factor of a coding macro block smaller than the standard scaling factor when the coding system of a coding block is an interframe coding system, when types of the motion vector of the coding macro block and the motion vectors of macro blocks around the coding macro block are detected, and when the type of the motion vector of the coding macro block differs from the type of the motion vectors of the macro blocks around the coding macro block. By protecting regions for a moving object and regions whose motion vector is large, code amounts can be controlled with high precision according to the characteristics of pictures.

[0055] In addition, a motion vector detection portion properly switches a plurality of predictive operation methods with respect to an inputted picture, and wherein a code amount control means calculates the importance for each macro block, and sets the importance of a coding macro block high when the coding system of a coding block is an interframe coding system and when the type of a first motion vector detected for each macro block differs from the type of a second motion vector detected for each super block comprising a plurality of macro blocks. By protecting regions for a moving object and regions whose motion vector is large, code amounts can be controlled with high precision according to the characteristics of pictures.

[0056] Furthermore, the importance calculation means detects importances with respect to T orthogonal transformation blocks that belong to the macro block, and defines the highest importance among the detected T importances as the importance of the macro block.

[0057] Moreover, the importance calculation means detects the importance for each orthogonal transformation block, and sets all data of the block after orthogonal transformation to 0 and sets the activity of the orthogonal transformation block to 0 when the block is determined as unimportant.

BRIEF DESCRIPTION OF THE DRAWINGS

[0058]FIG. 1 shows a flow of a coding process according to first, third and fifth embodiments of the present invention;

[0059]FIG. 2 shows a flow of a coding process according to second, fourth and sixth embodiments of the present invention;

[0060]FIG. 3 is a block diagram of a coding device according to seventh and eighth embodiments of the present invention;

[0061]FIG. 4 shows a unit configuration in the seventh and eighth embodiments of the present invention;

[0062]FIG. 5 is a block diagram of a coding device according to ninth to twenty-third embodiments of the present invention;

[0063]FIG. 6 is a graph showing an activity function in the ninth embodiment of the present invention;

[0064]FIG. 7 is a graph showing the relationship between a generated code amount and a prediction model in the ninth embodiment of the present invention;

[0065]FIG. 8 is a graph showing the relationship between a generated code amount and a prediction model in the tenth embodiment of the present invention;

[0066]FIG. 9 is a graph showing the relationship between a generated code amount and a prediction model in a modification of the tenth embodiment of the present invention;

[0067]FIG. 10 is a graph showing the relationship between a generated code amount and a prediction model in another modification of the tenth embodiment of the present invention;

[0068]FIG. 11 is a graph showing the relationship between a generated code amount and a prediction model in further modification the tenth embodiment of the present invention;

[0069]FIG. 12 is a graph showing the relationship between a generated code amount and a prediction model in the eleventh embodiment of the present invention;

[0070]FIG. 13 shows motion vectors of a coding macro block and macro blocks around the coding macro block in the twentieth embodiment of the present invention;

[0071]FIG. 14 shows motion vectors of a coding macro block and macro blocks around the coding macro block in a modification of the twentieth embodiment of the present invention;

[0072]FIG. 15 is a block diagram of a coding device according to a twenty-fourth embodiment of the present invention;

[0073]FIG. 16 is a block diagram of a conventional coding device using an intra-GOP interframe code amount control system;

[0074]FIG. 17 is a block diagram of a conventional coding device using a feedback type intraframe inter-macro-block code amount control system; and

[0075]FIG. 18 is a block diagram of a conventional coding device using a feedforward type intraframe inter-macro-block code amount control system.

BEST MODE FOR CARRYING OUT THE INVENTION

[0076] Preferred embodiments of the present invention will be described below with reference to the drawings.

[0077] (First Embodiment)

[0078]FIG. 1 shows a flow of a coding process according to a first embodiment of the present invention. To simplify the description, the coding control range is selected as four frames. This frame structure corresponds to N=4 and M=3 in a GOP structure of the MPEG. In FIG. 1, I0, B1, B2, P3, I4, B5, B6 and P7 represent frames in input order. The letters represent picture types of the MPEG (I represents an I picture, B represents a B picture, and P represents a P picture), and the numbers represent the inputted frame orders.

[0079] Also, 100 indicates a process for detecting the motion of B1 from I0. 101 indicates a process for detecting the motion of B2 from I0, 102 indicates a process for detecting the motion of P3 from I0, 103 indicates a process for detecting the motion of B1 from the frames I0 and P3 which are located before and after B1, and 104 indicates a process for detecting the motion of B2 from the frames I0 and P3 which are located before and after B2. The detection of the motion of a frame from frames which are located before and after the frame means, for example, the detection of vectors of a frame from the average value of frames which are located before and after the frame.

[0080] The target code amount in the GOP structure (N=4 and M=3) in this embodiment is set for 1 GOP (I0, B1, B2 and P3) in FIG. 1 as a unit. In FIG. 1, the horizontal axis represents time, indicating that the process 100 is performed at time 1, that the process 101 is performed at time 2, and that the processes 102, 103 and 104 are performed at time 3.

[0081] Therefore, all of the processes 100, 101, 102, 103 and 104 have ended at time 4. In this embodiment, differential data after detecting the motion in the process 102 (that is, the P3 picture whose motion is detected) is paid attention to, and the assignment of code amounts to the frames in a code amount assignment control range is controlled according to the sum of the absolute values of the differential data. For example, the following cases are shown.

[0082] [Case 1] the case where the sum of the absolute values of the differential data is larger than a first threshold

[0083] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=2:2:1:1

[0084] [Case 2] the case where the sum of the absolute values of the differential data is smaller than a second threshold

[0085] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=9:3:1:1

[0086] [Case 3] the case where the absolute values of the differential data is in the range of the second threshold to the first threshold

[0087] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=4:2:1:1

[0088] Thus, the code amounts can be controlled according to the characteristics of pictures by changing the ratio of the code amount assigned to each frame according to the sum of the absolute values of the differential data. Especially, changes in pictures in a GOP can be predicted according to the differential information of the P picture. Thus, even in scene-changed pictures or pictures whose motion changes greatly, which are a conventional problem, code amounts can be assigned according to the characteristics of pictures. (In this case, the ratio of the code amounts approaches I0:P3:B1:B2=2:2:1:1.) Therefore, the process of this embodiment can achieve a higher picture quality than conventional processes at the same bit rate. Furthermore, the process of this embodiment can achieve the same picture quality at a bit rate lower than that of the conventional processes.

[0089] (Second Embodiment)

[0090]FIG. 2 shows a flow of a coding process according to a second embodiment of the present invention. To simplify the description, the coding control range is selected as four frames in this embodiment as well. This frame structure corresponds to N=4 and M=2 of a GOP structure in the MPEG. In FIG. 2, P-1, B0, I1, B2, P3, B4, I5, B6 and P7 represent frames in input order. The letters represent picture types of the MPEG, and the numbers represent the inputted frame orders.

[0091] Also, 110 indicates a process for detecting the motion of B0 from P-1. 111 indicates a process for detecting the motion of B0 from the frames P-1 and I1 which are located before and after B0, 112 indicates a process for detecting the motion of B2 from I1, 113 indicates a process for detecting the motion of P3 from I1, and 114 indicates a process for detecting the motion of B2 from the frames I1 and P3 which are located before and after B2.

[0092] The target code amount in the GOP structure (N=4 and M=2) in this embodiment is set for 1 GOP (B0, I1, B2 and P3) in FIG. 2 as a unit. In FIG. 2, the horizontal axis represents time, indicating that the process 110 is performed at time 0, that the process 111 is performed at time 1, that the process 112 is performed at time 2, and that the processes 113 and 114 are performed at time 3.

[0093] Therefore, all of the processes 110, 111, 112, 113 and 114 have ended at time 4. In this embodiment, differential data after detecting the motion in the process 204 (that is, the P3 picture whose motion is detected) is paid attention to, and the assignment of code amounts to the frames in a code amount assignment control range is controlled according to the sum of the absolute values of the differential data. For example, the following cases are shown.

[0094] [Case 1] the case where the sum of the absolute values of the differential data is larger than a first threshold

[0095] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=2:2:1:1

[0096] [Case 2] the case where the sum of the absolute values of the differential data is smaller than a second threshold

[0097] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=9:3:1:1

[0098] [Case 3] the case where the absolute values of the differential data is in the range of the second threshold to the first threshold

[0099] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=4:2:1:1

[0100] Thus, the code amounts can be controlled according to the characteristics of pictures by changing the ratio of the code amount assigned to each frame according to the sum of the absolute values of the differential data. Especially, changes in pictures in a GOP can be predicted according to the differential information of the P picture. Thus, even in scenechanged pictures or pictures whose motion changes greatly, which are a conventional problem, code amounts can be assigned according to the characteristics of pictures. (In this case, the ratio of the code amounts approaches I1:P3:B0:B2=2:2:1:1.) Therefore, the process of this embodiment can achieve a higher picture quality than conventional processes at the same bit rate. Furthermore, the process of this embodiment can achieve the same picture quality at a bit rate lower than that of the conventional processes.

[0101] (Third Embodiment)

[0102] A third embodiment of the present invention will be described with reference to FIG. 1. To simplify the description, the coding control range is selected as four frames in this embodiment as well. This frame structure corresponds to N=4 and M=3 in a GOP structure of the MPEG. The basic operation based on FIG. 1 in this embodiment is the same as that in the first embodiment. However, this embodiment is characterized in that the assignment of code amounts to frames in a code amount assignment control range is controlled according to the motion vectors and the differential data after detecting the motion in the process 100, the motion vectors and the differential data after detecting the motion in the process 101, and the motion vectors and the differential data after detecting the motion in the process 102.

[0103] For determining the assignment of code amounts, the following four conditions are set.

[0104] (Condition 1) The sum of the absolute values of the differential data of B1 with respect to I0 is larger than a first threshold.

[0105] (Condition 2) The sum of the absolute values of the differential data of B2 with respect to I0 is larger than a second threshold.

[0106] (Condition 3) The sum of the absolute values of the differential data of P3 with respect to I0 is larger than a third threshold.

[0107] (Condition 4) The absolute value of the difference between the motion vectors of P3 with respect to I0 and the motion vectors of B1 with respect to I0 extended to the time 3 is smaller than a fourth threshold, and the absolute value of the difference between the motion vectors of P3 with respect to I0 and the motion vectors of B2 with respect to I0 extended to the time 3 is smaller than a fifth threshold.

[0108] The following code amount assignment is performed using the above conditions.

[0109] [Case 1] the case where none of the conditions 1, 2, 3 and 4 are satisfied

[0110] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=4:2:1:1

[0111] [Case 2] the case where only the condition 1 is satisfied

[0112] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=3:3:2:2

[0113] [Case 3] the case where only the condition 2 is satisfied

[0114] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=3:3:2:2

[0115] [Case 4] the case where only the condition 3 is satisfied

[0116] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=3:3:2:2

[0117] [Case 5] the case where the conditions 1 and 2 are satisfied

[0118] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=3:3:3:2

[0119] [Case 6] the case where the conditions 2 and 3 are satisfied

[0120] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=3:3:2:3

[0121] [Case 7] the case where the conditions 1 and 3 are satisfied

[0122] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=1:1:1:1

[0123] [Case 8] the case where the conditions 1, 2 and 3 are satisfied

[0124] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=1:1:1:1

[0125] [Case 9] the case where the condition 4 is satisfied

[0126] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=9:3:1:1

[0127] Thus, the code amounts can be controlled corresponding to the characteristics of pictures by performing code amount assignment considering the easiness of the motion prediction. Especially, changes in pictures in a GOP can be predicted according to the differential information of the P picture. Thus, even in scene-changed pictures or pictures whose motion changes greatly, which are a conventional problem, code amounts can be assigned according to the characteristics of pictures. (In this case, the ratio of the code amounts approaches I0:P3:B1:B2=1:1:1:1.) Therefore, the process of this embodiment can achieve a higher picture quality than conventional processes at the same bit rate. Furthermore, the process of this embodiment can achieve the same picture quality at a bit rate lower than that of the conventional processes.

[0128] (Fourth Embodiment)

[0129] A fourth embodiment of the present invention will be described with reference to FIG. 2. To simplify the description, the coding control range is selected as four frames in this embodiment as well. This frame structure corresponds to N=4 and M=2 in a GOP structure of the MPEG. The basic operation based on FIG. 2 in this embodiment is the same as that in the second embodiment. However, this embodiment is characterized in that the assignment of code amounts to frames in a code amount assignment control range is controlled according to the motion vectors and the differential data after detecting the motion in the process 111, the motion vectors and the differential data after detecting the motion in the process 112, and the motion vectors and the differential data after detecting the motion in the process 113.

[0130] For determining the assignment of code amounts, the following four conditions are set.

[0131] (Condition 1) The sum of the absolute values of the differential data of B0 with respect to I1 is larger than a first threshold.

[0132] (Condition 2) The sum of the absolute values of the differential data of B2 with respect to I1 is larger than a second threshold.

[0133] (Condition 3) The sum of the absolute values of the differential data of P3 with respect to I1 is larger than a third threshold.

[0134] (Condition 4) The absolute value of the difference between the motion vectors of P3 with respect to I1 and the motion vectors of B0 with respect to I1 extended to the time 3 is smaller than a fourth threshold, and the absolute value of the difference between the motion vectors of P3 with respect to I1 and the motion vectors of B2 with respect to I1 extended to the time 3 is smaller than a fifth threshold.

[0135] The following code amount assignment is performed using the above conditions.

[0136] [Case 1] the case where none of the conditions 1, 2, 3 and 4 are satisfied

[0137] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=4:2:1:1

[0138] [Case 2] the case where only the condition 1 is satisfied

[0139] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=3:3:2:2

[0140] [Case 3] the case where only the condition 2 is satisfied

[0141] (the code amount assigned to Il):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=3:3:2:2

[0142] [Case 4] the case where only the condition 3 is satisfied

[0143] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=3:3:2:2

[0144] [Case 5] the case where the conditions 1 and 2 are satisfied

[0145] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=3:3:3:2

[0146] [Case 6] the case where the conditions 2 and 3 are satisfied

[0147] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=3:3:2:3

[0148] [Case 7] the case where the conditions 1 and 3 are satisfied

[0149] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=1:1:1:1

[0150] [Case 8] the case where the conditions 1, 2 and 3 are satisfied

[0151] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=1:1:1:1

[0152] [Case 9] the case where the condition 4 is satisfied

[0153] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=9:3:1:1

[0154] Thus, the code amounts can be controlled according to the characteristics of pictures by performing code amount assignment considering the easiness of the motion prediction. Especially, changes in pictures in a GOP can be predicted according to the differential information of the P picture. Thus, even in scene-changed pictures or pictures whose motion changes greatly, which are a conventional problem, code amounts can be assigned according to the characteristics of pictures. (In this case, the ratio of the code amounts approaches I1:P3:B0:B2=1:1:1:1.) Therefore, the process of this embodiment can achieve a higher picture quality than conventional processes at the same bit rate. Furthermore, the process of this embodiment can achieve the same picture quality at a bit rate lower than that of the conventional processes.

[0155] (Fifth Embodiment)

[0156] A fifth embodiment of the present invention will be described with reference to FIG. 1. To simplify the description, the coding control range is selected as four frames in this embodiment as well. This frame structure corresponds to N=4 and M=3 in a GOP structure of the MPEG. The basic operation based on FIG. 1 in this embodiment is the same as that in the first embodiment. However, this embodiment is characterized in that an activity operation is performed with respect to the frame I0, that the degree of difficulty of coding the frame I0 is detected by the detected activity, and that the assignment of code amounts to the frames in a code amount assignment control range is controlled according to differential data after detecting the motion in the process 103.

[0157] The degrees of difficulty of coding are classified into the following three ranks according to the value of the activity detected in the activity operation with respect to the frame I0.

[0158] (Rank 1) The activity is larger than a first threshold.

[0159] (Rank 2) The activity is smaller than a second threshold.

[0160] (Rank 3) The activity is in the range of the second threshold to the first threshold.

[0161] In other words, the rank 1 indicates that the degree of difficulty of coding is high, the rank 2 indicates that the degree of difficulty of coding is low, and the rank 3 indicates that the degree of difficulty of coding is moderate. In this embodiment, the degree of difficulty of coding is determined from the activity. As another method, it is also considered that coding is actually performed to determine the degree of difficulty from an average scaling factor and generated code amounts.

[0162] The following code amount assignment is performed using the above ranks and the differential data.

[0163] [Case 1] The rank of the frame I0 is 1, and the absolute value of the differential data is larger than a third threshold.

[0164] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=2:1:1:1

[0165] [Case 2] The rank of the frame I0 is 1, and the absolute value of the differential data is smaller than a fourth threshold.

[0166] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=12:3:1:1

[0167] [Case 3] The rank of the frame I0 is 1, and the absolute value of the differential data is in the range of the fourth threshold to the third threshold.

[0168] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=9:3:1:1

[0169] [Case 4] The rank of the frame I0 is 2, and the absolute value of the differential data is larger than the third threshold.

[0170] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=1:1:1:1

[0171] [Case 5] The rank of the frame I0 is 2, and the absolute value of the differential data is smaller than the fourth threshold.

[0172] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=6:3:1:1

[0173] [Case 6] The rank of the frame I0 is 2, and the absolute value of the differential data is in the range of the fourth threshold to the third threshold.

[0174] (the code amount assigned to I0):(the code amount assigned to P3): (the code amount assigned to B1):(the code amount assigned to B2)=4:2:1:1

[0175] [Case 7] The rank of the frame I0 is 3, and the absolute value of the differential data is larger than the third threshold. (the code amount assigned to I0):(the code amount assigned to P3):

[0176] (the code amount assigned to B1):(the code amount assigned to B2)=1:1:1:1 [Case 8] The rank of the frame I0 is 3, and the absolute value of the differential data is smaller than the fourth threshold. (the code amount assigned to I0):(the code amount assigned to P3):

[0177] (the code amount assigned to B1):(the code amount assigned to B2)=9:3: 1:1 [Case 9] The rank of the frame I0 is 3, and the absolute value of the differential data is in the range of the fourth threshold to the third threshold. (the code amount assigned to I0):(the code amount assigned to P3):

[0178] (the code amount assigned to B1):(the code amount assigned to B2)=4:2:1: 1

[0179] Thus, the code amounts can be controlled according to the characteristics of pictures by performing the code amount assignment as described above. Especially, changes in pictures in a GOP can be predicted according to the differential information of the P picture. Thus, even in scene-changed pictures or pictures whose motion changes greatly, which are a conventional problem, code amounts can be assigned according to the characteristics of pictures. (In this case, the ratio of the code amounts approaches I0:P3:B1:B2=1:1:1:1.) Therefore, the process of this embodiment can achieve a higher picture quality than conventional processes at the same bit rate. Furthermore, the process of this embodiment can achieve the same picture quality at a bit rate lower than that of the conventional processes.

[0180] (Sixth Embodiment)

[0181] A sixth embodiment of the present invention will be described with reference to FIG. 2. To simplify the description, the coding control range is selected as four frames in this embodiment as well. This frame structure corresponds to N=4 and M=2 in a GOP structure of the MPEG. The basic operation based on FIG. 2 in this embodiment is the same as that in the second embodiment. However, this embodiment is characterized in that an activity operation is performed with respect to the frame I1, that the degree of difficulty of coding the frame I1 is detected by the detected activity, and that the assignment of code amounts to the frames in a code amount assignment control range is controlled according to differential data after detecting the motion in the process 113.

[0182] The degrees of difficulty of coding are classified into the following three ranks according to the value of the activity detected in the activity operation with respect to the frame I1.

[0183] (Rank 1) The activity is larger than a first threshold.

[0184] (Rank 2) The activity is smaller than a second threshold.

[0185] (Rank 3) The activity is in the range of the second threshold to the first threshold.

[0186] In other words, the rank 1 indicates that the degree of difficulty of coding is high, the rank 2 indicates that the degree of difficulty of coding is low, and the rank 3 indicates that the degree of difficulty of coding is moderate. In this embodiment, the degree of difficulty of coding is determined from the activity. As another method, it is also considered that coding is actually performed to determine the degree of difficulty from an average scaling factor and generated code amounts.

[0187] The following code amount assignment is performed using the above ranks and the differential data.

[0188] [Case 1] The rank of the frame I1 is 1, and the absolute value of the differential data is larger than a third threshold.

[0189] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=2:1:1:1

[0190] [Case 2] The rank of the frame I1 is 1, and the absolute value of the differential data is smaller than a fourth threshold.

[0191] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=12:3:1:1

[0192] [Case 3] The rank of the frame I1 is 1, and the absolute value of the differential data is in the range of the fourth threshold to the third threshold.

[0193] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=9:3:1:1

[0194] [Case 4] The rank of the frame I1 is 2, and the absolute value of the differential data is larger than the third threshold.

[0195] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=1:1:1:1

[0196] [Case 5] The rank of the frame I1 is 2, and the absolute value of the differential data is smaller than the fourth threshold.

[0197] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=6:3:1:1

[0198] [Case 6] The rank of the frame I1 is 2, and the absolute value of the differential data is in the range of the fourth threshold to the third threshold.

[0199] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=4:2:1:1

[0200] [Case 7] The rank of the frame I1 is 3, and the absolute value of the differential data is larger than the third threshold.

[0201] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=1:1:1:1

[0202] [Case 8] The rank of the frame I1 is 3, and the absolute value of the differential data is smaller than the fourth threshold.

[0203] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=9:3:1:1

[0204] [Case 9] The rank of the frame I1 is 3, and the absolute value of the differential data is in the range of the fourth threshold to the third threshold.

[0205] (the code amount assigned to I1):(the code amount assigned to P3): (the code amount assigned to B0):(the code amount assigned to B2)=4:2:1:1

[0206] Thus, the code amounts can be controlled according to the characteristics of pictures by performing the code amount assignment as described above. Especially, changes in pictures in a GOP can be predicted according to the differential information of the P picture. Thus, even in scene-changed pictures or pictures whose motion changes greatly, which are a conventional problem, code amounts can be assigned according to the characteristics of pictures. (In this case, the ratio of the code amounts approaches I1:P3:B0;B2=1:1:1:1.) Therefore, the process of this embodiment can achieve a higher picture quality than conventional processes at the same bit rate. Furthermore, the process of this embodiment can achieve the same picture quality at a bit rate lower than that of the conventional processes.

[0207] (Seventh Embodiment)

[0208]FIG. 3 shows a block diagram of a coding device according to a seventh embodiment of the present invention. In FIG. 3, 200 denotes a motion vector detection portion, 201 denotes a differential picture generation portion, 202 denotes a unit division portion, 203 denotes an activity calculation portion, 204 denotes an average unit activity updating portion, 205 denotes a target code amount determination portion, 206 denotes a coding portion, 207 denotes an assigned code amount updating portion, and 208 denotes a local decoder.

[0209] The operation of the coding device comprising the above-described configuration will be described with reference to FIG. 4. For the convenience of explanation, the frame frequency is 60 fps, the GOP structure is N=30 and M=3, and the bit rate is 6 Mbps. These conditions are the same in the following embodiments. In FIG. 4, (a) indicates inputted pictures, (b) indicates frame activities found with respect to the inputted pictures, (c) indicates unit activities found with respect to the inputted pictures, and (d) indicates target code amounts set with respect to the inputted pictures.

[0210] In FIG. 3, a picture signal is inputted to the motion vector detection portion 200 and the differential picture generation portion 201. When the inputted picture is a P or B picture, the motion vector detection portion 200 detects motion vectors with respect to reference picture(s) stored in the memory and outputs the motion vectors. When the inputted picture is an I picture, the motion vector detection portion 200 does not detect motion vectors. The motion vectors outputted from the motion vector detection portion 200 are inputted to the differential picture generation portion 201.

[0211] When the inputted picture is a P or B picture, the differential picture generation portion 201 generates a predicted picture from the inputted motion vectors and decoded reference picture(s) inputted from the local decoder, calculates the differences between the predicted picture and the inputted picture, and outputs a differential picture. The differential picture is inputted to the unit division portion 202, the activity calculation portion 203, and the coding portion 206. When the inputted picture is an I picture, the inputted picture is inputted to the unit division portion 202, the activity calculation portion 203, and the coding portion 206.

[0212] The unit division portion 202 defines an I unit comprising one I picture and two B pictures and a P unit comprising one P picture and two B pictures as shown in FIG. 4 (a), determines whether the inputted differential picture belongs to the I or P unit according to the picture type of the inputted differential picture, and outputs the information of the unit. The unit information is inputted to the activity calculation portion 203. The activity calculation portion 203 performs an activity operation with respect to the inputted difference signal and outputs a frame activity as shown in FIG. 4 (b).

[0213] Furthermore, the activity calculation portion 203 outputs the unit activity of the unit to which the differential picture belongs from the inputted unit information as shown in FIG. 4 (c). The frame activity is inputted to the target code amount determination portion 205. The unit activity is inputted to the average unit activity updating portion 204 and the target code amount determination portion 205. The average unit activity updating portion 204 updates the average unit activity of the inputted unit from the inputted unit activity.

[0214] When the inputted unit is a P unit, the average unit activity updating portion 204 updates the average unit activity of the P unit APm according to the following equation (1):

APm=(APm+Aa)/2  (1)

[0215] where Aa is unit activity and APm is the average unit activity of the P unit.

[0216] When the inputted unit is an I unit, the average unit activity updating portion 204 updates the average unit activity of the I unit AIm according to the following equation (2):

AIm=(AIm+Aa)/2  (2)

[0217] where Aa is unit activity and AIm is the average unit activity of the I unit.

[0218] The updated average unit activity is inputted to the target code amount determination portion 205. The target code amount determination portion 205 outputs a target code amount with respect to a coding frame from the inputted frame activity, unit activity, average unit activity and assigned code amount as shown in FIG. 4 (d). The target code amount of the unit Tu is found from the following equation (3):

Tu=R×Aa/(AIm+APm×9)  (3)

[0219] where Aa is the activity of the inputted unit, AIm is the average activity of I units which have been inputted previously, APm is the average activity of P units which have been inputted previously, and R is assigned code amount.

[0220] The assigned code amount R is a code amount assigned to a code amount assignment control range when the control range is set, and is being updated according to the generated code amount of a unit. In this embodiment, code amounts are controlled with 10 units, so that the initial value of R is 6M×(10/20)=3M bits. The target code amount of the coding frame Tf is found from the following equation (4):

Tf=Tu×Af/Aa  (4)

[0221] where Af is the activity of the coding frame.

[0222] The target code amount is inputted to the coding portion 206. The coding portion 206 encodes the inputted differential picture with the inputted target code amount and outputs encoded data. The encoded data is inputted to the assigned code amount updating portion 207 and the local decoder 208. The assigned code amount updating portion 207 calculates a generated code amount from the inputted encoded data and updates the assigned code amount R. The local decoder 208 decodes the inputted encoded data and generates a decoded picture.

[0223] Thus, code amounts can be controlled with a higher precision by dividing pictures into the I unit comprising an I picture and B pictures and the P unit comprising a P picture and B pictures and controlling code amounts unit by unit.

[0224] (Eighth Embodiment)

[0225] An eighth embodiment of the present invention will be described with reference to FIG. 3. The configuration of FIG. 3 and the basic operation in this embodiment are the same as those in the seventh embodiment. However, the activity calculation portion 203 in this embodiment multiplies the calculated activity by a weighting constant with respect to an I picture KI when the frame is an I picture, multiplies the calculated activity by a weighting constant with respect to a P picture KP when the frame is a P picture, and multiplies the calculated activity by a weighting constant with respect to a B picture KB when the frame is a B picture. A new activity obtained by the multiplication is defined as the activity of the frame.

[0226] For example, when the activities of the I, P and B pictures before weighting are 10,000, 7,000 and 5,000 respectively, and the weighting constants of the I, P and B pictures are KI=1.0, KP=0.8 and KB=0.5 respectively, the activities of the I, P and B pictures after weighting operation are 10,000, 5,600 and 2,500.

[0227] Thus, code amounts can be controlled with a higher precision by performing a weighting operation according to the picture type of the frame with respect to an activity calculated for each frame and controlling the code amount using a new activity obtained by the weighting operation.

[0228] (Ninth Embodiment)

[0229]FIG. 5 shows a block diagram of a coding device according to a ninth embodiment of the present invention. In FIG. 5, 300 denotes a motion vector detection portion, 301 denotes a differential picture generation portion, 302 denotes an orthogonal transformation portion, 303 denotes an importance calculation portion, 304 denotes an activity calculation portion, 305 denotes a target code amount determination portion, 306 denotes a reference scaling factor calculation portion, 307 denotes a coding portion, and 308 denotes a local decoder. The operation of the coding device having such a configuration will be described with reference to FIG. 6 and FIG. 7.

[0230] In FIG. 5, a picture signal is inputted to the motion vector detection portion 300, the differential picture generation portion 301, and the importance calculation portion 303. When the inputted picture is a P or B picture, the motion vector detection portion 300 detects motion vectors with respect to reference picture(s) stored in the memory and outputs the motion vectors. When the inputted picture is an I picture, the motion vector detection portion 300 does not detect motion vectors. The motion vectors outputted from the motion vector detection portion 300 are inputted to the differential picture generation portion 301 and the importance calculation portion 303.

[0231] When the inputted picture is an I picture, the differential picture generation portion 301 outputs the inputted picture as a differential picture. When the inputted picture is a P or B picture, the differential picture generation portion 301 generates a predicted picture from the inputted motion vectors and decoded reference picture(s) inputted from the local decoder 308, calculates the differences between the predicted picture and the inputted picture, and outputs a differential picture. The differential picture is inputted to the orthogonal transformation portion 302, the importance calculation portion 303, and the activity calculation portion 304.

[0232] The orthogonal transformation portion 302 performs the orthogonal transformation operation of the inputted differential picture and outputs orthogonal transformation data. The orthogonal transformation data is inputted to the importance calculation portion 303 and the coding portion 307.

[0233] The importance calculation portion 303 calculates a visual importance for each macro block from the motion vectors, the inputted picture, the orthogonal transformation data and the differential picture, each of which is inputted to the importance calculation portion 303, and quantifies the importance by ranking as a class. A macro block whose class is low is quantized by a scaling factor smaller than a reference scaling factor which is a standard in quantization. A macro block whose class is high is quantized by a scaling factor larger than the reference scaling factor. The detected importance is inputted to the activity calculation portion 304 and the coding portion 307.

[0234] The activity calculation portion 304 calculates an activity for each macro block with respect to the inputted differential picture using the information of the importance provided by the importance calculation portion 303 and generates an activity function indicating the accumulation of the activity for each macro block as shown in FIG. 6 and a frame activity indicating the activity of the whole coding frame. The activity function and the frame activity are inputted to the target code amount determination portion 305, the reference scaling factor calculation portion 306, and the coding portion 307.

[0235] The target code amount determination portion 305 determines the target code amount of the coding frame by using at least one of the frame activity of the coding frame, the target code amount, the remaining code amount at the time of coding the coding frame, the frame activity of frames which have been encoded previously, and the occupancy of the buffer, each of which is inputted to the target code amount determination portion 305. The target code amount is inputted to the reference scaling factor calculation portion 306 and the coding portion 307.

[0236] The reference scaling factor calculation portion 306 calculates the reference scaling factor of the coding frame by using at least one of the target code amount, the frame activity of the coding frame, the generated code amount of the previously encoded frames, and the average scaling factor of the previously encoded frames, each of which is inputted to the reference scaling factor calculation portion 306. The reference scaling factor is inputted to the coding portion 307.

[0237] The coding portion 307 generates the prediction model of a generated code amount from the inputted target code amount and activity function, quantizes the orthogonal transformation data for each macro block according to the reference scaling factor and the importance detected for each macro block, performs variable length coding, and outputs encoded data. The encoded data is inputted to the target code amount determination portion 305, the reference scaling factor calculation portion 306, and the local decoder 308. The local decoder 308 decodes the inputted encoded data and generates a decoded picture. The decoded picture is inputted to the differential picture generation portion 301.

[0238] The operation of the coding portion 307 will be described with reference to FIG. 7. In FIG. 7, a prediction model 501 is the prediction model of a generated code amount found from an activity function 500 as shown in FIG. 6. A generated code amount 502 is a generated code amount in actual coding. The coding portion 307 controls the reference scaling factor based on the difference between the prediction model 501 and the generated code amount 502.

[0239] Thus, code amounts can be controlled with high precision according to the characteristics of pictures by generating the prediction model of a generated code amount from an activity indicating the characteristics of a picture with respect to a coding frame, performs coding along the prediction model, and controlling the reference scaling factor based on the difference between a generated code amount and the prediction model.

[0240] Furthermore, compared with the feedforward type intraframe inter-macro-block code amount control described as prior art, the coding device of this embodiment does not require a plurality of code amount pre-reading portions. Therefore, the coding device of this embodiment can be implemented with a smaller circuit. In other words, code amounts can be controlled with high precision according to the characteristics of pictures with a smaller circuit.

[0241] (Tenth Embodiment)

[0242] A tenth embodiment of the present invention will be described with reference to FIGS. 5, 8, 9, 10 and 11. The configuration of FIG. 5 and the basic operation in this embodiment are the same as those in the ninth embodiment. However, the coding portion 307 in this embodiment sets a region with a specific width with respect to a prediction model, encodes a differential picture macro block by macro block according to a reference scaling factor and an importance detected for each macro block, and corrects the reference scaling factor according to a deviation amount when a generated code amount deviates from the region set for the prediction model. The operation of the coding portion 307 will be described with reference to FIG. 8. In FIG. 8, a prediction model 503 is the prediction model of the generated code amount found from the activity function 500 as shown in FIG. 6. A generated code amount 505 is a generated code amount in actual coding. A region 504 is a region with a specific width with respect to the prediction model 503. When the generated code amount deviates from the region 504, the reference scaling factor is corrected according to the deviation amount.

[0243] For example, when the width of the region 504 is 1,000 bits and the difference between the generated code amount 505 and the prediction model 503 is larger than 1,000 bits, the reference scaling factor is increased by one. On the contrary, when the difference between the generated code amount 505 and the prediction model 503 is smaller than −1,000 bits, the reference scaling factor is decreased by one.

[0244] It is also considered that when the generated code amount deviates from the region, the reference scaling factor, the prediction model, the target code amount and the region are corrected according to the deviation amount. This correction method will be described with reference to FIG. 9. In FIG. 9, a prediction model 506 is a prediction model before correction and the prediction model of the generated code amount found from the activity function 500 as shown in FIG. 6. A region 509 is a region set for the prediction model before correction 506. A prediction model 507 is a prediction model after correction. A region 510 is a region set for the prediction model after correction 507. A generated code amount 508 is a generated code amount in actual coding. When the generated code amount 508 deviates from the region 509 set for the prediction model before correction 506, the reference scaling factor, the prediction model, the target code amount, and the region are corrected according to the deviation amount.

[0245] For example, when the width of the region 509 is 1,000 bits and the difference between the generated code amount 508 and the prediction model 506 is 1,100 bits, which is larger than 1,000 bits, the reference scaling factor is increased by one, and the prediction model and the region are shifted upward by the difference between the generated code amount and the prediction model. In this example, the prediction model and the region are shifted upward by 1,100 bits.

[0246] On the contrary, when the difference between the generated code amount 508 and the prediction model 506 is −1,100 bits, which is smaller than −1,000 bits, the reference scaling factor is decreased by one, and the prediction model and the region are shifted downward by the difference between the generated code amount and the prediction model. In this example, the prediction model and the region are shifted downward by 1,100 bits.

[0247] When the generated code amount deviates from the region set for the prediction model, the reference scaling factor, the prediction model, the target code amount, and the region are corrected according to the deviation amount. Therefore, the final generated code amount differs from the target code amount set at the start of coding. However, the probability of an occurrence of a new correction can be reduced after correction. Thus, the fluctuation of the reference scaling factor can be reduced, so that a stable picture quality can be obtained. In addition, while the width of the region is constant in this embodiment, the width can be changed according to the inclination of the prediction model.

[0248] Since the prediction model is calculated from the activity function, the shape of the prediction model reflects the characteristics of each macro block. For example, when the inclination of the prediction model is high, the activity of the macro block is large, indicating that the macro block is a region including an edge. On the contrary, when the inclination of the prediction model is low, the activity of the macro block is small, indicating that the macro block is a flat region.

[0249] In a region where the inclination of the prediction model is high, the fluctuation of the generated code amount depending on the fluctuation of the reference scaling factor is greater than that in a region where the inclination of the prediction model is low. Therefore, when the width set for the prediction model is constant regardless of the inclination of the prediction model and is set small based on the region where the inclination of the prediction model is low, the reference scaling factor fluctuates drastically in the region where the inclination of the prediction model is high. On the contrary, when the width is set large based on the region where the inclination of the prediction model is high, the reference scaling factor is not corrected in the region where the inclination of the prediction model is low even if a reference scaling factor that is not suited to the prediction model is selected. Therefore, it is difficult to perform coding according to the characteristics of the picture.

[0250] In particular, unless the reference scaling factor is corrected, the error of the target code amount is large. Therefore, a sufficient code amount cannot be assigned when coding a macro block having a large activity and requiring a large code amount. Accordingly, the width is changed according to the inclination of the prediction model. The width is set large as the inclination is higher, and the width is set small as the inclination is lower. Thus, control can be performed according to the characteristics of the picture.

[0251]FIG. 10 shows an example in which the width of the prediction model is changed according to the inclination of the prediction model and in which the reference scaling factor is corrected according to a deviation amount when the generated code amount deviates from the region. In FIG. 10, a region 513 changes according to the inclination of a prediction model 511. The region 513 is large as the inclination of the prediction model is higher, and the region 513 is small as the inclination of the prediction model is lower. When a generated code amount 512 deviates from the region 513 in coding, the reference scaling factor is operated according to the deviation amount. For example, when the generated code amount 512 is larger than the region 513, the reference scaling factor is increased by one. On the contrary, when the generated code amount 512 is smaller than the region 513, the reference scaling factor is decreased by one.

[0252]FIG. 11 shows an example in which the width of the prediction model is changed according to the inclination of the prediction model and in which the reference scaling factor, the prediction model, the target code amount, and the region are corrected according to a deviation amount when the generated code amount deviates from the region. In FIG. 11, a prediction model 514 is a prediction model before correction and the prediction model of the generated code amount found from the activity function 500 as shown in FIG. 6. A region 517 is a region set for the prediction model before correction 514. A prediction model 515 is a prediction model after correction. A region 518 is a region set for the prediction model after correction 515. A generated code amount 516 is a generated code amount in actual coding. When the generated code amount 516 deviates from the region 517 set for the prediction model before correction 514, the reference scaling factor, the prediction model, the target code amount, and the region are corrected according to the deviation amount.

[0253] Thus, code amounts can be controlled with high precision according to the characteristics of pictures by generating the prediction model of a generated code amount from an activity indicating the characteristics of a picture with respect to a coding frame, setting a region having a predetermined width with respect to the prediction model, performs coding along the prediction model, and correcting at least one of the reference scaling factor, the prediction model, the target code amount, and the region according to a deviation amount when the generated code amount deviates from the region.

[0254] Furthermore, compared with the feedforward type intraframe inter-macro-block code amount control described as prior art, the coding device of this embodiment does not require a plurality of code amount pre-reading portions. Therefore, the coding device of this embodiment can be implemented with a smaller circuit. In other words, code amounts can be controlled with high precision according to the characteristics of pictures with a smaller circuit.

[0255] (Eleventh Embodiment)

[0256] An eleventh embodiment of the present invention will be described with reference to FIGS. 5 and 12. The configuration of FIG. 5 and the basic operation in this embodiment are the same as those in the ninth embodiment. However, the coding portion 307 in this embodiment sets the width of a prediction model according to the inclination of the prediction model, sets a check point for each S (an integer of 2 or more) macro blocks, and corrects the reference scaling factor according to a deviation amount when a generated code amount deviates from this region at the check point. The reference scaling factor is not corrected even if the generated code amount deviates from the region other than the check point.

[0257] When a scaling factor changes in a picture, the degree of quantization error changes at the point of the change, causing discontinuity. The discontinuity causes a visual deterioration. Therefore, it is desirable that the scaling factor is constant in a picture. Accordingly, in this embodiment, a check point is set for each S macro blocks, and the reference scaling factor is corrected according to a deviation amount only when the generated code amount deviates from the region at the check point. Thus, the stability of the picture quality can be improved.

[0258] As described above, in this embodiment, S is an integer of 2 or more. If S is set to one macro block line, the change of the reference scaling factor always occurs at the edges of the screen, so that the visual deterioration can be reduced. If S is set to a number expressed by a power of 2, the counter at the check point can be operated only by bit shift, contributing to the reduction of the size of the circuit.

[0259] Furthermore, it is also considered that the reference scaling factor, the predicted mode, the target code amount, and the region are corrected according to a deviation amount only when the generated code amount deviates from the region at the check point.

[0260] Thus, the stability of the picture quality can be improved and code amounts can be controlled with high precision according to the characteristics of pictures by generating the prediction model of a generated code amount from an activity indicating the characteristics of a picture with respect to a coding frame, performing coding along the prediction model, correcting the reference scaling factor according to a deviation amount when the generated code amount deviates from the region at a check point set for each S macro blocks.

[0261] Furthermore, compared with the feedforward type intraframe intermacro-block code amount control described as prior art, the coding device of this embodiment does not require a plurality of code amount pre-reading portions. Therefore, the coding device of this embodiment can be implemented with a smaller circuit. In other words, code amounts can be controlled with high precision according to the characteristics of pictures with a smaller circuit.

[0262] (Twelfth Embodiment)

[0263] A twelfth embodiment of the present invention will be described with reference to FIG. 5. The configuration of FIG. 5 and the basic operation in this embodiment are the same as those in the ninth embodiment. However, the importance calculation portion 303 in this embodiment calculates importances with respect to T (an integer) orthogonal transformation blocks that belong to the same macro block, finds the sum of the absolute values of AC components with respect to the orthogonal transformation data of the orthogonal transformation block when the coding system of the coding macro block is an interframe coding system and when the coding frame is a B picture, and sets the importance of the block high if the sum of the absolute values of the AC components is larger than a specific threshold.

[0264] According to this embodiment, the code amount of the whole picture can be reduced to a constant value or less while restraining the deterioration of the picture quality by protecting regions for a moving object or regions whose detected motion is large.

[0265] (Thirteenth Embodiment)

[0266] A thirteenth embodiment of the present invention will be described with reference to FIG. 5. The configuration of FIG. 5 and the basic operation in this embodiment are the same as those in the ninth embodiment. However, the importance calculation portion 303 in this embodiment calculates importances with respect to T orthogonal transformation blocks that belong to the same macro block, finds the sum of the absolute values of AC components with respect to the orthogonal transformation data of the orthogonal transformation block when the coding system of the coding macro block is an interframe coding system and when the coding frame is a B picture, and sets all orthogonal transformation data of the block to 0 if the sum of the absolute values of the AC components is smaller than a specific threshold.

[0267] According to this embodiment, the code amount of the whole picture can be reduced to a constant value or less while restraining the deterioration of the picture quality by generating a reproduced picture only with motion compensation with respect to regions where motion detection is effective and providing code amounts to other regions.

[0268] (Fourteenth Embodiment)

[0269] A fourteenth embodiment of the present invention will be described with reference to FIG. 5. The configuration of FIG. 5 and the basic operation in this embodiment are the same as those in the ninth embodiment. However, the importance calculation portion 303 in this embodiment calculates importances with respect to T orthogonal transformation blocks that belong to the same macro block. When the coding system of the picture to be encoded is an interframe coding system, the importance calculation portion 303 calculates the number of sampling values having a larger value than a first threshold with respect to the sampling values of a Y-R component block in a first macro block formed by macro blocking the original picture, and sets the importance of the block high if the number of the sampling values is larger than a predetermined number (for example, 8).

[0270] Thus, regions containing a red color having a high chroma can be protected. Therefore, the code amount of the whole picture can be reduced to a constant value or less while restraining the deterioration of the picture quality.

[0271] (Fifteenth Embodiment)

[0272] A fifteenth embodiment of the present invention will be described with reference to FIG. 5. The configuration of FIG. 5 and the basic operation in this embodiment are the same as those in the ninth embodiment. However, the importance calculation portion 303 in this embodiment calculates importances with respect to T orthogonal transformation blocks that belong to the same macro block. When the coding system of the picture to be encoded is an interframe coding system, the importance calculation portion 303 calculates the number of sampling values having a larger value than a first threshold with respect to the sampling values of a Y-B component block in a first macro block formed by macro blocking the original picture, and sets the importance of the block high if the number is larger than a predetermined number (for example, 8).

[0273] Thus, regions containing a blue color having a high chroma can be protected. Therefore, the code amount of the whole picture can be reduced to a constant value or less while restraining the deterioration of the picture quality.

[0274] (Sixteenth Embodiment)

[0275] A sixteenth embodiment of the present invention will be described with reference to FIG. 5. The configuration of FIG. 5 and the basic operation in this embodiment are the same as those in the ninth embodiment. However, the importance calculation portion 303 in this embodiment performs the following process. An importance is calculated with respect to a macro block. When the coding system of the picture to be encoded is an interframe coding system, the number of sampling values having a value in the range of a first threshold to a second threshold is calculated with respect to a Y component block in a first macro block formed by macro blocking the original picture, and the number of the sampling values is defined as a first detected value. Then, the number of sampling values having a value in the range of a third threshold to a fourth threshold is calculated with respect to a Y-R component block in the first macro block, and the number of the sampling values is defined as a second detected value. Furthermore, the number of sampling values having a value in the range of a fifth threshold to a sixth threshold is calculated with respect to a Y-B component block in the first macro block, and the number of the sampling values is defined as a third detected value. When the first detected value is larger than a first predetermined number, when the second detected value is larger than a second predetermined number, and when the third detected value is larger than a third predetermined number, the importances of the blocks are set high.

[0276] Thus, regions containing a specific color (for example, a skin color) can be protected. Therefore, the code amount of the whole picture can be reduced to a constant value or less while restraining the deterioration of the picture quality.

[0277] (Seventeenth Embodiment)

[0278] A seventeenth embodiment of the present invention will be described with reference to FIG. 5. The configuration of FIG. 5 and the basic operation in this embodiment are the same as those in the ninth embodiment. However, the importance calculation portion 303 in this embodiment performs the following process. Importances are calculated with respect to T orthogonal transformation blocks that belong to the same macro block. When the coding system of the picture to be encoded is an interframe coding system, the number of sampling values in which the absolute value of the difference between a sampling value of a Y-R component block and a sampling value of a Y-B component block is larger than a first threshold is calculated with respect to the Y-B component block and the Y-R component block in a first macro block formed by macro blocking the original picture. If the number of the sampling values is larger than a predetermined number, the importances of the Y-R block and the Y-B block are set high.

[0279] Thus, regions containing a red or blue color having a high chroma can be protected. Therefore, the code amount of the whole picture can be reduced to a constant value or less while restraining the deterioration of the picture quality.

[0280] (Eighteenth Embodiment)

[0281] An eighteenth embodiment of the present invention will be described with reference to FIG. 5. The configuration of FIG. 5 and the basic operation in this embodiment are the same as those in the ninth embodiment. However, the importance calculation portion 303 in this embodiment performs the following process. Importances are calculated with respect to T orthogonal transformation blocks that belong to the same macro block. When the coding system of the picture to be encoded is an interframe coding system, activities are calculated with respect to blocks in a first macro block formed by macro blocking the original picture, and the sum of the absolute values of AC components is calculated with respect to the orthogonal transformation data of the block. If the activity is larger than a first threshold and the sum of the absolute values of the AC components is larger than a second threshold, the importance of the block is set low.

[0282] According to this embodiment, the code amount of the whole picture can be reduced to a constant value or less while restraining the deterioration of the picture quality by not protecting regions where visual deterioration is not noticeable (reducing code amounts assigned to the regions) and assigning large code amounts to other regions.

[0283] (Nineteenth Embodiment)

[0284] A nineteenth embodiment of the present invention will be described with reference to FIG. 5. The configuration of FIG. 5 and the basic operation in this embodiment are the same as those in the ninth embodiment. However, the importance calculation portion 303 in this embodiment calculates an importance with respect to a macro block, and if the macro block is located at the upper end, lower end, left end, or right end of the screen, the importance calculation portion 303 sets the importance of the macro block low.

[0285] According to this embodiment, the code amount of the whole picture can be reduced to a constant value or less while restraining the deterioration of the picture quality by not protecting regions where visual deterioration is not noticeable (reducing code amounts assigned to the regions) and assigning large code amounts to other regions.

[0286] (Twentieth Embodiment)

[0287] A twentieth embodiment of the present invention will be described with reference to FIGS. 5, 13 and 14. The configuration of FIG. 5 and the basic operation in this embodiment are the same as those in the ninth embodiment. However, the importance calculation portion 303 in this embodiment calculates an importance with respect to a macro block, compares the motion vector of the coding macro block and the motion vectors of macro blocks around the coding macro block when the coding system of the picture to be encoded is an interframe coding system, and sets the importance of the macro block high if the types of the vectors are different.

[0288]FIG. 13 shows motion vectors when a picture to be encoded is a B picture. The motion vector of a coding macro block is (8,0) backward predictive, and the motion vectors of macro blocks around the coding macro block are (8,0) forward predictive. When the types of the motion vector of a coding macro block and the motion vectors of macro blocks around the coding macro block are different in this manner, the importance of the coding macro block is set high according to this embodiment.

[0289] As shown in FIG. 14, the scaling factor can be controlled based on the quantity of the motion vector. FIG. 14 shows motion vectors when a picture to be encoded is a P picture. The motion vector of a coding macro block is (4,4) forward predictive, and the motion vectors of macro blocks around the coding macro block are (8,0) forward predictive. Here, (x,y) of a motion vector indicates motion in the horizontal direction by x samples and motion in the vertical direction by y samples.

[0290] When the sum of the absolute values of the differences between the motion vector of the coding macro block and the motion vectors of the macro blocks around the coding macro block is defined as a vector difference, the calculated vector difference is (|4−8|+|4−0)×8=64. The calculated vector difference is larger than a threshold (for example, 32), so that the importance of the coding macro block is set high.

[0291] Thus, according to this embodiment, regions for a moving object and regions whose detected motion is large can be protected. Therefore, the code amount of the whole picture can be reduced to a constant value or less while restraining the deterioration of the picture quality.

[0292] (Twenty-first Embodiment)

[0293] A twenty-first embodiment of the present invention will be described with reference to FIG. 5. The configuration of FIG. 5 and the basic operation in this embodiment are the same as those in the ninth embodiment. However, this embodiment differs from the ninth embodiment in the following points.

[0294] The motion vector detection portion 300 forms a super block comprising a plurality of macro blocks including a coding macro block and detects a motion vector for each super block. For the convenience of explanation, a motion vector detected for each super block is referred to as a second vector, and a motion vector detected for each macro block is referred to as a first vector.

[0295] The importance calculation portion 303 calculates an importance with respect to a macro block. When the coding system of a picture to be encoded is an interframe coding system, the importance calculation portion 303 compares a first motion vector detected with respect to a coding macro block and a second motion vector detected with respect to a super block including the macro block, and sets the importance of the macro block high if the types of the vectors are different.

[0296] In addition, the importance calculation portion 303 calculates the sum of the absolute values of the difference between the first motion vector and the second motion vector, and sets the importance of this macro block high if the sum is larger than a threshold.

[0297] Thus, regions for a moving object and regions whose detected motion is large can be protected. Therefore, the code amount of the whole picture can be reduced to a constant value or less while restraining the deterioration of the picture quality.

[0298] (Twenty-second Embodiment)

[0299] A twenty-second embodiment of the present invention will be described with reference to FIG. 5. The configuration of FIG. 5 and the basic operation in this embodiment are the same as those in the ninth embodiment. However, the importance calculation portion 303 in this embodiment detects an importance for each of T orthogonal transformation blocks that belong to the same macro block, and defines the highest importance among the T importances as the importance of the macro block.

[0300] Thus, code amounts can be controlled with high precision according to the characteristics of pictures by detecting an importance for each orthogonal transformation block with respect to a coding frame and defining the highest of the importances of the orthogonal transformation blocks that belong to the same macro block as the importance of the macro block.

[0301] Furthermore, compared with the feedforward type intraframe inter-macro-block code amount control described as prior art, the coding device of this embodiment does not require a plurality of code amount pre-reading portions. Therefore, the coding device of this embodiment can be implemented with a smaller circuit. In other words, code amounts can be controlled with high precision according to the characteristics of pictures with a smaller circuit.

[0302] (Twenty-third Embodiment)

[0303] A twenty-third embodiment of the present invention will be described with reference to FIG. 5. The configuration of FIG. 5 and the basic operation in this embodiment are the same as those in the ninth embodiment. However, the importance calculation portion 303 in this embodiment detects an importance for each of T orthogonal transformation blocks that belong to the same macro block. If the importance calculation portion 303 determines that the importance is low, it sets the class of the orthogonal transformation block to 5. After the coding portion 307 sets all data of the class 5 orthogonal transformation blocks to 0 and sets the activities of the orthogonal transformation blocks to 0, the importance calculation portion 303 defines the highest of the importances of the orthogonal transformation blocks that belong to the same macro block as the importance of the macro block.

[0304] Thus, code amounts can be controlled with high precision according to the characteristics of pictures by detecting an importance for each orthogonal transformation block with respect to a coding frame, setting all data to 0 with respect to the orthogonal transformation blocks whose importance is determined as low, and defining the highest of the importances of the orthogonal transformation blocks that belong to the same macro block as the importance of the macro block.

[0305] Furthermore, compared with the feedforward type intraframe inter-macro-block code amount control described as prior art, the coding device of this embodiment does not require a plurality of code amount pre-reading portions. Therefore, the coding device of this embodiment can be implemented with a smaller circuit. In other words, code amounts can be controlled with high precision according to the characteristics of pictures with a smaller circuit. 

1. A picture signal coding method comprising the steps of defining N continuous frames as one coding control unit, performing intraframe coding of a first frame of the coding control unit without using a difference between frames, coding an Nth frame using a difference between the Nth frame and the first frame, and coding a second frame to a (N−1)th frame using both difference between the second to the (N−1)th frame and the first frame and difference between the second to the (N−1)th frame and the Nth frame, wherein target code amounts of all frames of the coding control unit are set considering the difference between the first frame and the Nth frame as an index.
 2. A picture signal coding method comprising the steps of defining N continuous frames as one coding control unit, performing intraframe coding of a Kth frame of the coding control unit without using a difference between frames, coding an Nth frame using a difference between the Nth frame and the Kth frame, coding a first frame to a (K−1)th frame using both difference between the first to the (K−1)th frame and an Nth frame of the latest previous coding control unit and difference between the first to the (K−1)th frame and the Kth frame of the current coding control unit, and coding a (K+1)th frame to a (N−1)th frame using both difference between the (K+1)th to the (N−1)th frame and the Kth frame of the current coding control unit and difference between the (K+1)th to the (N−1)th frame and the Nth frame of the current coding control unit, wherein target code amounts of all frames of the current coding control unit are set considering the difference between the Nth frame and the Kth frame as an index.
 3. A picture signal coding method comprising the steps of defining N continuous frames as one coding control unit, performing intraframe coding of a first frame of the coding control unit without using a difference between frames, coding an Nth frame using a difference between the Nth frame and the first frame, and coding a second frame to a (N−1)th frame using both difference between the second to the (N−1)th frame and the first frame and difference between the second to the (N−1)th frame and the Nth frame, wherein a scene change in the coding control unit is detected based on a motion amount of the Nth frame from the first frame and a motion amount of each of the second frame to the (N−1)th frame from the first frame, and target code amounts of all frames of the coding control unit are set considering a result of the scene change detection as an index.
 4. A picture signal coding method comprising the steps of defining N continuous frames as one coding control unit, performing intraframe coding of a Kth frame of the coding control unit without using a difference between frames, coding an Nth frame using a difference between the Nth frame and the Kth frame, coding a first frame to a (K−1)th frame using both difference between the first to the (K−1)th frame and an Nth frame of the latest previous coding control unit and difference between the first to the (K−1)th frame and the Kth frame of the current coding control unit, and coding a (K+1)th frame to a (N−1)th frame using both difference between the (K+1)th to the (N−1)th frame and the Kth frame of the current coding control unit and difference between the (K+1)th to the (N−1)th frame and the Nth frame of the current coding control unit, wherein a scene change in the coding control unit is detected based on a motion amount of the Nth frame from the Kth frame and a motion amount of each of the first frame to the (K−1)th frame and the (K+1)th frame to the (N−1)th frame from the Kth frame, and target code amounts of all frames of the coding control unit are set considering a result of the scene change detection as an index.
 5. A picture signal coding method comprising the steps of defining N continuous frames as one coding control unit, performing intraframe coding of a first frame of the coding control unit without using a difference between frames, coding an Nth frame using a difference between the Nth frame and the first frame, and coding a second frame to a (N−1)th frame using both difference between the second to the (N−1)th frame and the first frame and difference between the second to the (N−1)th frame and the Nth frame, wherein a degree of difficulty of coding picture signals in the coding control unit is detected from an activity calculated with respect to the first frame, and target code amounts of all frames of the coding control unit are set considering the degree of difficulty and the difference between the Nth frame and the first frame as indices.
 6. A picture signal coding method comprising the steps of defining N continuous frames as one coding control unit, performing intraframe coding of a Kth frame of the coding control unit without using a difference between frames, coding an Nth frame using a difference between the Nth frame and the Kth frame, coding a first frame to a (K−1)th frame using both difference between the first to the (K−1)th frame and an Nth frame of the latest previous coding control unit and difference between the first to the (K−1)th frame and the Kth frame of the current coding control unit, and coding a (K+1)th frame to a (N−1)th frame using both difference between the (K+1)th to the (N−1)th frame and the Kth frame of the current coding control unit and difference between the (K+1)th to the (N−1)th frame and the Nth frame of the current coding control unit, wherein a degree of difficulty of coding picture signals in the coding control unit is detected from an activity calculated with respect to the Kth frame, and target code amounts of all frames of the coding control unit are set considering the degree of difficulty and the difference between the Nth frame and the Kth frame as indices.
 7. A picture signal coding device comprising: a unit division means for divining inputted pictures into coding control units comprising one or plurality of frames that are to be subjected to a process selected from the group consisting of an intraframe coding process, an interframe forward coding process, and an interframe bidirectionally predictive coding process; an activity calculation means for calculating a frame activity from each frame of the inputted pictures and calculating a unit activity for each unit from the frame activities of the frames that belong to the unit; a target code amount determination means for determining a target code amount of a coding frame based on a frame activity of the coding frame, a unit activity of a coding unit to which the coding frame belongs, and an average unit activity of previous units; and a coding means for coding the coding frame with the target code amount to generate encoded data.
 8. The picture signal coding device according to claim 7, wherein the frame activity calculated for each frame is multiplied by one of three weighting constants predetermined according to whether the coding frame is an I, P or B picture, and a resulting value is used as the frame activity.
 9. A picture signal coding device comprising: an activity function generation means for calculating an activity for each macro block in each frame of inputted pictures, generating an activity function indicating an accumulation of the activity for each macro block in a coding frame, and calculating a frame activity of the coding frame; a target code amount determination means for determining a target code amount of the coding frame by using at least one of a remaining code amount at the time of coding the coding frame, a generated code amount of previously encoded frames, an activity of the previously encoded frames, an occupancy of a buffer, and the activity of the coding frame; a reference scaling factor calculation means for calculating a reference scaling factor of the coding frame by using at least one of a scaling factor of the previously encoded frames, the generated code amount of the previously encoded frames, the frame activity of the previously encoded frames, the frame activity of the coding frame, and the target code amount; an importance calculation means for detecting a visual importance for each macro block; and a coding means for generating a prediction model based on the activity function and the target code amount, coding the coding frame macro block by macro block by using the prediction model, the reference scaling factor, and the importance, and generating encoded data.
 10. A picture signal coding device comprising: an activity function generation means for calculating an activity for each macro block in each frame with respect to inputted pictures, generating an activity function indicating an accumulation of the activity for each macro block in a coding frame, and calculating a frame activity of the coding frame; a target code amount determination means for determining a target code amount of the coding frame by using at least one of a remaining code amount at the time of coding the coding frame, a generated code amount of previously encoded frames, an activity of the previously encoded frames, an occupancy of a buffer, and the activity of the coding frame; a reference scaling factor calculation means for calculating a reference scaling factor of the coding frame by using at least one of a scaling factor of the previously encoded frames, the generated code amount of the previously encoded frames, the frame activity of the previously encoded frames, the frame activity of the coding frame, and the target code amount; an importance calculation means for detecting a visual importance for each macro block; and a coding means for generating a prediction model based on the activity function and the target code amount, setting a region with a specific width with respect to the prediction model, coding the coding frame macro block by macro block by using the reference scaling factor and the importance, correcting at least one of the reference scaling factor, the prediction model, the target code amount, and the region according to a deviation amount when an accumulation of a generated code amount for each macro block deviates from the region, and generating encoded data.
 11. The picture signal coding device according to claim 9 or 10, wherein the coding means sets a check point for each integer macro blocks and determines whether the accumulation of the generated code amount for each macro block deviates from the region at the check point or not.
 12. The picture signal coding device according to claim 9 or 10, wherein the importance calculation means calculates the importance for each orthogonal transformation block, calculates a sum of absolute values of AC components in orthogonal transformation data of the orthogonal transformation block when a coding system of a coding block is an interframe coding system and when the coding frame is a B picture, and sets the importance of the orthogonal transformation block high if the sum of the absolute values is larger than a threshold.
 13. The picture signal coding device according to claim 9 or 10, wherein the importance calculation means calculates the importance for each orthogonal transformation block, calculates a sum of absolute values of AC components in orthogonal transformation data of the orthogonal transformation block when a coding system of a coding block is an interframe coding system and when the coding frame is a B picture, and sets all orthogonal transformation data of the orthogonal transformation block to 0 if the sum of the absolute values is smaller than a threshold.
 14. The picture signal coding device according to claim 9 or 10, wherein the importance calculation means calculates the importance for each orthogonal transformation block; calculates number of sampling values having a larger value than a threshold among sampling values of a Y-R component block in the orthogonal transformation block with respect to an inputted picture for which a differential operation for motion compensation is not performed, when a coding system of a coding block is an interframe coding system; and sets the importance of the orthogonal transformation block high if the number of the sampling values is larger than a predetermined value.
 15. The picture signal coding device according to claim 9 or 10, wherein the importance calculation means calculates the importance for each orthogonal transformation block; calculates number of sampling values having a larger value than a threshold among sampling values of a Y-B component block in the orthogonal transformation block with respect to an inputted picture for which a differential operation for motion compensation is not performed, when a coding system of a coding block is an interframe coding system; and sets the importance of the orthogonal transformation block high if the number of the sampling values is larger than a predetermined value.
 16. The picture signal coding device according to claim 9 or 10, wherein the importance calculation means calculates the importance for each orthogonal transformation block; calculates number of sampling values having a value in the range of a first threshold to a second threshold with respect to a Y component block in a coding macro block and defines the number of the sampling values as a first detected value, calculates number of sampling values having a value in the range of a third threshold to a fourth threshold with respect to a Y-R component block in the coding macro block and defines the number of the sampling values as a second detected value, and calculates number of sampling values having a value in the range of a fifth threshold to a six threshold with respect to a Y-B component block in the coding macro block and defines the number of the sampling values as a third detected value, with respect to an inputted picture for which a differential operation for motion compensation is not performed, when a coding system of a coding block is an interframe coding system; and sets the importance of the orthogonal transformation block high when the first detected value is larger than a first number, when the second detected value is larger than a second number, and when the third detected value is larger than a third number.
 17. The picture signal coding device according to claim 9 or 10, wherein the importance calculation means calculates the importance for each orthogonal transformation block; calculates number of sampling values in which absolute value of a difference between a sampling value of a Y-R component block and a sampling value of a Y-B component block is larger than a threshold with respect to the Y-B component block and the Y-R component block in a coding macro block, with respect to an inputted picture for which a differential operation for motion compensation is not performed, when a coding system of a coding block is an interframe coding system; and sets the importance of the coding macro block high if the number of the sampling values is larger than a predetermined value.
 18. The picture signal coding device according to claim 9 or 10, wherein the importance calculation means calculates the importance for each orthogonal transformation block; calculates an activity of the orthogonal transformation block with respect to an inputted picture for which a differential operation for motion compensation is not performed and calculates a sum of absolute values of AC components in the orthogonal transformation block with respect to a differential picture for which a differential operation for motion compensation is performed when a coding system of a coding block is an interframe coding system; and sets the importance of the orthogonal transformation block low when the activity is larger than a first threshold and the sum of the absolute values of the AC components is larger than a second threshold.
 19. The picture signal coding device according to claim 9 or 10, wherein the importance calculation means calculates the importance for each macro block, and sets an importance of a coding macro block low when the coding macro block is located at one of an upper end, a lower end, a left end, and a right end of a screen.
 20. The picture signal coding device according to claim 9 or 10, wherein the importance calculation means calculates the importance for each orthogonal transformation block; and sets an importance of a coding macro block high when a coding system of a coding block is an interframe coding system, when types of a motion vector of the coding macro block and motion vectors of macro blocks around the coding macro block are detected, and when the type of the motion vector of the coding macro block differs from the type of the motion vectors of the macro blocks around the coding macro block.
 21. The picture signal coding device according to claim 9 or 10, wherein a motion vector detection portion properly switches a plurality of predictive operation methods with respect to an inputted picture, and wherein a code amount control means calculates the importance for each macro block, and sets an importance of a coding macro block high when a coding system of a coding block is an interframe coding system and when a type of a first motion vector detected for each macro block differs from a type of a second motion vector detected for each super block comprising a plurality of macro blocks.
 22. The picture signal coding device according to claim 9 or 10, wherein the importance calculation means detects importances with respect to T orthogonal transformation blocks that belong to the macro block, and defines a highest importance among the detected T importances as an importance of the macro block.
 23. The picture signal coding device according to claim 9 or 10, wherein the importance calculation means detects the importance for each orthogonal transformation block, and sets all data of the block after orthogonal transformation to 0 and sets an activity of the orthogonal transformation block to 0 when the block is determined as unimportant. 